<html lang="en"   xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="shortcut icon" href="/favicon.ico" mce_href="/favicon.ico" type="image/x-icon">

    <style type="text/css">
        #container{
            width: 650px;
            height: 430px;
            margin: 30px auto;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改个人信息</legend>
</fieldset>

<div id="container">
    <form class="layui-form" th:action="@{/user/modify}" method="post"
          enctype="multipart/form-data" onsubmit="return checkInformation()">

        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name"  th:value="${session.loginUser.user_name}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <select name="gender" lay-filter="aihao">
                    <div th:if="${session.loginUser.user_gender eq 1}">
                        <option value="1" selected>男</option>
                    </div>
                    <div th:if="${session.loginUser.user_gender eq 0}">
                        <option value="1">男</option>
                    </div>

                    <div th:if="${session.loginUser.user_gender eq 0}">
                        <option value="0" selected>女</option>
                    </div>
                    <div th:if="${session.loginUser.user_gender eq 1}">
                        <option value="0">女</option>
                    </div>
                </select>
            </div>
        </div>

        <div class="layui-form-item" >
            <label class="layui-form-label">年龄</label>
            <div class="layui-input-block">
                <input type="number" id="age" name="age" th:value="${session.loginUser.user_age}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-block">
                <input type="text" name="phone" id="phone"  th:value="${session.loginUser.getUser_phone()}" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item" style="margin-top: 20px;">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">提交修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script th:inline="javascript">
    var layer;
    layui.use("layer",function () {
        layer = layui.layer;
    });

    //如果数据校验通过返回true，不通过则返回false
    function checkInformation() {

        //1.校验姓名
        var name =document.getElementById("name").value;
        if(name == ""){
            layer.msg("姓名不能为空！");
            //alert("请输入姓名！");
            return false;
        }else if(name.length<1 || name.length>9){
            layer.msg("姓名长度必须为1-9个字符！");
            //alert("类别名称长度必须为2-40个字符！");
            return false;
        }

        //年龄
        var age =document.getElementById("age").value;
        if(age == ""){
            layer.msg("年龄不能为空！");
            //alert("请输入商品库存！");
            return false;
        }else if(age.length<1 || age.length>3){
            layer.msg("年龄长度必须为1-3个字符！");
            //alert("商品数量长度必须为1-9个字符！");
            return false;
        }

        //电话
        var phone =document.getElementById("phone").value;
        if(phone == ""){
            layer.msg("电话不能为空！");
            //alert("请输入求助金额！");
            return false;
        }else if(phone.length<1 || phone.length>11){
            layer.msg("电话长度必须为1-11个字符！");
            //alert("商品价格长度必须为1-11个字符！");
            return false;
        }
        return true;
    }
</script>
<script type="text/javascript" th:src="@{/layui/layui.all.js}"></script>

</body>
</html>
